// ==UserScript==
// @name           SFEEAddNewTrackerToImageArea
// @namespace      oasis.mitra.com
// @description    Make it easy to create a new tracker
// @include        http://oasis.mitra.com*/sf*
// ==/UserScript==

var tableRow = document.evaluate(
    "//tr[@class='ButtonRow']",
    document,
    null,
    XPathResult.ANY_TYPE,
    null);
    
var tr = tableRow.iterateNext();

var documentsNode;
var children = tr.cells;
for( var i = 0; i < children.length; i++ )
{
	var child = children[i];
	if( child.innerHTML != "" && child.innerHTML.indexOf('<br>Documents') >= 0 )
	{
		documentsNode = child;
		break;
	}
}

var newTracker = document.createElement("td");
newTracker.setAttribute('class', 'Button');
newTracker.setAttribute("onclick", "window.location = 'http://oasis.mitra.com:8080/sf/tracker/do/createArtifact/projects.agility_solution_build/tracker.development_imagearea';");
newTracker.innerHTML = '<a href="http://oasis.mitra.com:8080/sf/tracker/do/createArtifact/projects.agility_solution_build/tracker.development_imagearea" target="_top"><img src="/sf-images/project/project-wikiicon.gif" width="25" height="20" border="0"><br>New Image Area Tracker</a>';

var divider = document.createElement("td");
divider.setAttribute('class', 'VerticalSeparatorNoBorder');
divider.innerHTML = '<img src="/sf-images/misc/white.gif" border="0" height="40" width="1">';

tr.insertBefore(newTracker, documentsNode);
tr.insertBefore(divider, documentsNode);
